﻿using FDStudio.Core.Config.SE;
using FDStudio.Core.Entities;
using FDStudio.Core.Services;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;

namespace FDStudio.Core.Search
{
    /*
     CreatedOn: 2018-03-13
     CreatedBy: Jackie Lee(天宇遊龍)
     */
    /// <summary>
    /// 搜索接口
    /// </summary>
    public interface ISearchEngine : IService
    {
        /// <summary>
        /// 搜索名称
        /// </summary>
        string Name { get; set; }

        IApiResult BuildIndex<T>(IList<T> data) where T : IEntity;

        /// <summary>
        /// 默认权重字段都为1
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="condition"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totalRecord"></param>
        /// <returns></returns>
        IList<T> Search<T>(string condition, int pageSize, int pageIndex, out int totalRecord) where T : IEntity;

        /// <summary>
        /// 设置权重及字符串匹配搜索
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="keyword"></param>
        /// <param name="fieldWeights">字段权重</param>
        /// <param name="wildcardFields">字符串匹配的字符</param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totalRecord"></param>
        /// <returns></returns>
        IList<T> Search<T>(string keyword, IList<FieldWeight> fieldWeights, IList<string> wildcardFields, int pageSize, int pageIndex, out int totalRecord) where T : IEntity;

    }
}
